import request from '@/utils/request'
// import qs from 'qs'
// 日志记录

// 查询数据
export function logRecord (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/logRecord',
    method: 'post',
    data
  })
}

// 查询会话版子数据
export function sessionChild (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/sessionChild',
    method: 'post',
    data
  })
}

// 清空日志
export function cleanDpLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/cleanDpLog',
    method: 'post',
    data
  })
}

// 旧版管理日志

// 查询管理日志
export function searchLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/searchLog',
    method: 'post',
    data
  })
}

// 导出
export function exportMgmtLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/exportSearchLog',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 查询管理日志
export function searchMgmtLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/searchLog',
    method: 'post',
    data
  })
}

// 清空日志
export function cleanMgmtLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/cleanMgmtLog',
    method: 'post',
    data
  })
}

// 获取所属模块信息
export function getMgmtMode (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/getMgmtMode',
    method: 'post',
    data
  })
}

// 旧版日志查询

// 获取数据
export function getLogSearch (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/getLogSearch',
    method: 'post',
    data
  })
}

// 会话搜索
export function sessionSearch (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/sessionSearch',
    method: 'post',
    data
  })
}

// 高级搜索
export function advancedSearch (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/advancedSearch',
    method: 'post',
    data
  })
}

// 获取所属模块信息
export function getMode (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/getMode',
    method: 'post',
    data
  })
}

// 日志导出

// 下载
export function downloadLog (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/downloadLog',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 删除
export function delLogExport (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/del_log_export',
    method: 'post',
    data
  })
}

// 增加导出任务
export function addLogExport (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/addLogExport',
    method: 'post',
    data
  })
}

// 获取导出任务列表
export function logExportList (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/logExportList',
    method: 'post',
    data
  })
}

// 获取事件信息
export function getEvent (params) {
  var data = fromData(params)
  return request({
    url: '/old_log/getEvent',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
